<?php
   class News extends MY_Controller{
	   public function __construct(){
		   parent::__construct();
		   $this->load->model("model_news");
           $this->load->model("model_home");
	   }
	   public function index(){
		   $id = (int)$this->uri->segment(3);	   
		   $data['read'] = $this->model_news->detail($id);
		   //$this->debug($data['read']);
		   if($data['read'] == NULL){
		   		redirect(base_url());
				exit();
		   }
		   //$data['liqu'] = $this->model_news->lienquan($lq,$id);
		   $data['title'] = $data['read']['news_title']." - News";
		   $this->load->view("news/detail/layout",$data);
	   }
	   public function all(){
		   $config['base_url'] = base_url().'home/news/all/';
		   $config['total_rows'] = $this->model_news->count_all_news();
		   $config['per_page'] = 5;
		   $config['uri_segment'] = 4;
		   $config['next_link'] = "Next";
		   $config['prev_link'] = "Prev";
		   $this->load->library("pagination",$config);
		   $start = (int)$this->uri->segment(4);
		   $data['config']    = $this->config();
		   $data['hottours']  = $this->hottours();		   
		   $data['listnews'] = $this->model_news->list_all($config['per_page'],$start);
		   //$this->debug($data['listnews']);
		   $data['introduc']    = $this->model_index->intro();
		   $data['title'] = "Travel news";
		   $this->load->view("news/all/layout",$data); 
	   }
   }